<template>
  <el-menu :default-active="this.$store.state.menus.editableTabsValue" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff"
           active-text-color="#ffd04b">
    <router-link to="/index">
      <el-menu-item index="Index" @click="selectMenu({name:'Index', title:'首页'})">
        <template slot="title">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </template>
      </el-menu-item>
    </router-link>

    <el-submenu :index="itms.name" v-for="itms in menuList">
      <template slot="title">
        <i :class="itms.icon"></i>
        <span>{{ itms.title }}</span>
      </template>
      <router-link :to="items1.path" v-for="items1 in itms.children">
        <el-menu-item :index="items1.name" @click="selectMenu(items1)">
          <template slot="title">
            <i :class="items1.icon"></i>
            <span slot="title">{{ items1.title }}</span>
          </template>
        </el-menu-item>
      </router-link>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  name: "SideMenu",
  data() {
    return {

    }
  },
  computed:{
    menuList :{
      get(){
        return this.$store.state.menus.menuList
      }
    }
  },
  methods:{
    selectMenu(items1){
      this.$store.commit("addTab",items1)
    }
  }
}
</script>

<style scoped>
.el-menu-vertical-demo {
  height: 100%;
}
</style>